package com.hwadee.ems.domain.vo;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.hwadee.ems.domain.po.User;
import com.hwadee.ems.enums.UserRole;
import com.hwadee.ems.service.IClassService;
import com.hwadee.ems.service.IDepartmentService;
import com.hwadee.ems.service.impl.ClassServiceImpl;
import com.hwadee.ems.service.impl.DepartmentServiceImpl;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserVO {

    @JsonIgnore
    private IClassService classService = ClassServiceImpl.getInstance();

    @JsonIgnore
    private IDepartmentService departmentService = DepartmentServiceImpl.getInstance(); 

    public UserVO(User user) {
        this.id = user.getId();
        this.name = user.getName();
        this.number = user.getNumber();
        this.classId = user.getClassId();
        this.className = classService.getById(this.classId).getName();
        this.departmentId = user.getDepartmentId();
        this.departmentName = departmentService.getById(this.departmentId).getName();
        this.role = user.getRole();
    }
    
    /**
     * 用户编号
     */
    private Long id;

    /**
     * 用户姓名
     */
    private String name;

    /**
     * 学号/工号
     */
    private String number;

    /**
     * 学生所属班级编号 references class(id) for (name)
     */
    private Long classId;

    /**
     * 学生所属班级名称
     */
    private String className;

    /**
     * 教师所属院系编号 references department(id) for (name)
     */
    private Long departmentId;

    /**
     * 教师所属院系名称
     */
    private String departmentName;

    /**
     * 用户角色，0代表学生，1代表教师，2代表教务员，3代表其他
     */
    private UserRole role;

}
